<template>
  <div style="width: 100%; height: 100%; margin-bottom: 10px">
    <el-row>
      <el-button size="mini" icon="el-icon-refresh-left" plain type="primary" @click="openData(true)">刷新</el-button>
      <el-button plain size="mini" type="warning" icon="el-icon-circle-plus-outline" @click="addModuleFileSet()"
        >增加文件映射</el-button
      >
      <el-button plain size="mini" type="danger" icon="el-icon-refresh" @click="InitFileManage()"
        >刷新中间件文件映射</el-button
      >
    </el-row>
    <!--弹出编辑界面 TModuleFileSet-->
    <el-dialog
      width="1000px"
      title="编辑文件配置"
      v-model="FShowEdit"
      :close-on-click-modal="false"
      destroy-on-close
    >
      <el-form :model="FIndexFileSet" label-width="100px">
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="文件代码">
              <el-input
                v-model="FIndexFileSet.FFileCode"
                placeholder="必须,配置代码"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="文件标签">
              <el-input
                v-model="FIndexFileSet.FSetCaption"
                placeholder="配置标签"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="账套代码">
              <el-input
                v-model="FIndexFileSet.FDBCode"
                placeholder="保存在哪个数据库配置"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!--  -->
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="物理路径">
              <el-input
                v-model="FIndexFileSet.FPhysicalPath"
                placeholder="文件保存实际硬盘地址"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="URL域名">
              <el-input
                v-model="FIndexFileSet.FHttpRoot"
                placeholder="通过Url访问域名"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!--  -->
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="web访问">
              <el-switch v-model="FIndexFileSet.FIsWeb"></el-switch>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="启用">
              <el-switch v-model="FIndexFileSet.FIsUse"></el-switch>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="与Base_file结构相同" label-width="150px">
              <el-switch v-model="FIndexFileSet.FIsBaseFile"></el-switch>
            </el-form-item>
          </el-col>
        </el-row>
        <!--  -->
        <el-row>
          <div align="center" style="width: 100%; height: 30px; color: red">
            -------------自定义保存的表,配置好相关字段即可--------------
          </div>
        </el-row>
        <!--  -->
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="保存表名">
              <el-input
                v-model="FIndexFileSet.FTableName"
                placeholder="要保存在哪张表"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="主键字段">
              <el-input
                v-model="FIndexFileSet.FFileIDField"
                placeholder="表的主键"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="文件字段">
              <el-input
                v-model="FIndexFileSet.FFileNameField"
                placeholder="文件名保存在哪个字段"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="类型字段">
              <el-input
                v-model="FIndexFileSet.FFileTypeField"
                placeholder="文件类型保存在哪个字段"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="长度字段">
              <el-input
                v-model="FIndexFileSet.FFileSizeField"
                placeholder="文件长度保存在哪个字段"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="路径字段">
              <el-input
                v-model="FIndexFileSet.FFilePathField"
                placeholder="文件路径保存在哪个字段"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!--  -->
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="时间字段">
              <el-input
                v-model="FIndexFileSet.FFileTimeField"
                placeholder="创建时间保存在哪个字段"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="URL路径">
              <el-input
                v-model="FIndexFileSet.FFileHttpField"
                placeholder="URL路径保存在哪个字段"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!--  -->
        <el-row>
          <div align="center" style="width: 100%; height: 30px; color: red">
            ------------提交的表单参数相关字段--------------
          </div>
        </el-row>
        <!--  -->
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="业务ID字段">
              <el-input
                v-model="FIndexFileSet.FJobField"
                placeholder="表单参数jobID"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业务明细字段">
              <el-input
                v-model="FIndexFileSet.FDetailField"
                placeholder="表单参数detailID"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="备注字段">
              <el-input
                v-model="FIndexFileSet.FRemarkField"
                placeholder="表单参数remark"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!--  -->
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="自定义字段">
              <el-input
                v-model="FIndexFileSet.FCustomerTagField"
                placeholder="表单参数customerTag"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="FShowAddModule = false">取 消</el-button>
          <el-button type="primary" @click="saveModuleFileSet()"
            >确 定</el-button
          >
        </span>
      </template>
    </el-dialog>
    <!--Grid列表 -->
    <div style="height: 15px"></div>
    <el-table :data="FFileSetList" border highlight-current-row>
      <el-table-column prop="FFileCode" label="配置代码"> </el-table-column>
      <el-table-column prop="FSetCaption" label="配置标签"> </el-table-column>
      <el-table-column prop="FIsBaseFile" label="BaseFile表"> </el-table-column>
      <el-table-column prop="FIsUse" label="启用" width="80"> </el-table-column>
      <el-table-column fixed="right" label="操作">
        <template #default="scope">
          <el-button plain type="primary" size="mini" icon="el-icon-edit" @click="editModuleFileSet(scope.row)">编辑</el-button>
          <el-button plain size="mini" type="danger" icon="el-icon-delete" @click="delModuleFileSet(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script lang="ts">
import { TModuleFileSet } from "@/baselib/module/BaseClass";
import BaseForm from "@/views/BaseForm";
export default class TFormModuleFileSet extends BaseForm {
  private FIndexFileSet: TModuleFileSet = new TModuleFileSet();
  private FFileSetList: TModuleFileSet[] = [];
  private FShowEdit: boolean = false;
  public created() {
    this.openData();
  }
  private async openData() {
    let lResult = await this.$myModuleAPI.getModuleFileSetList();
    if (!lResult.resultSuccess) {
      this.$myMsgHelp.msgDialog(lResult.resultMsg);
      return;
    }
    this.FFileSetList = lResult.resultData;
    this.$myMsgHelp.msgHintAutoClose("打开数据成功");
  }
  private addModuleFileSet() {
    this.FIndexFileSet = new TModuleFileSet();
    this.FShowEdit = true;
  }
  private editModuleFileSet(qFileSet: TModuleFileSet) {
    this.FIndexFileSet = qFileSet;
    this.FShowEdit = true;
  }
  private async saveModuleFileSet() {
    let lResult = await this.$myModuleAPI.saveModuleFileSet(this.FIndexFileSet);
    if (!lResult.resultSuccess) {
      this.$myMsgHelp.msgDialog(lResult.resultMsg);
      return;
    }
    this.FShowEdit = false;
    this.$myMsgHelp.msgHintAutoClose("保存数据成功");
    this.openData();
  }
  private async delModuleFileSet(qFileSet: TModuleFileSet) {
    if (this.$myStrHelper.stringIsEmptyYW(qFileSet.FSetID)) {
      this.$myMsgHelp.msgDialog("文件配置ID不可为空");
      return;
    }
    let lConfirm = await this.$myMsgHelp.msgDialogConfirm("确定删除文件配置");
    if (!lConfirm) {
      return;
    }
    let lResult = await this.$myModuleAPI.delModuleFileSet(qFileSet.FSetID);
    if (!lResult.resultSuccess) {
      this.$myMsgHelp.msgDialog(lResult.resultMsg);
      return;
    }
  }
}
</script>
<style>
</style>[yu]
